/**
 * 
 */
package de.cbf.cam.dsa.facet.armor.helper.editing_support;

import java.text.NumberFormat;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.jface.viewers.ColumnLabelProvider;

import de.cbf.cam.dsa.facet.armor.helper.ZoneFactors;

/**
 * @author salter
 *
 */
public class ZoneFactorsLabelProvider extends ColumnLabelProvider{
	private static final Log logger = LogFactory.getLog(ZoneFactorsLabelProvider.class);
	
	protected NumberFormat format;
	protected String zoneName;

	/**
	 * 
	 */
	public ZoneFactorsLabelProvider() {
	}
	
	@Override
	public String getText(Object element) {
		if (element instanceof ZoneFactors) {
			ZoneFactors zoneFactors = (ZoneFactors) element;
			Double factor = zoneFactors.getZoneFactor(zoneName);
			String text = format.format(factor);
			return text;
		} else {
			String err_msg = "entity of wrong type in getText : \n"
					+ "Expected: "
					+ ZoneFactors.class.getSimpleName()
					+ "\n"
					+ "Got: "
					+ (element == null ? "null" : element
							.getClass().getSimpleName());
			logger.error(err_msg);
		}
		return super.getText(element);
	}

	/**
	 * @return the format
	 */
	public NumberFormat getFormat() {
		return format;
	}

	/**
	 * @param format the format to set
	 */
	public void setFormat(NumberFormat format) {
		this.format = format;
	}

	/**
	 * @return the zoneName
	 */
	public String getZoneName() {
		return zoneName;
	}

	/**
	 * @param zoneName the zoneName to set
	 */
	public void setZoneName(String zoneName) {
		this.zoneName = zoneName;
	}	
}
